﻿/* ######################################## *\
 * ### Copyright (C) 2009 AJ Ravindiran ### *
 * ### HTTP://THEAJ.NET/ <AJ@THEAJ.NET> ### *
\* ######################################## */
using System;
using System.Security.Cryptography;
using System.Text;

namespace AJRavindiran.Jolt.Utilities
{
    /// <summary>
    /// Represents a SHA512 Cryptograpy method.
    /// </summary>
    public class SHA512
    {
        /// <summary>
        /// Hashes a string input to SHA512 angorithm.
        /// </summary>
        /// <param name="input">The value to be hashed.</param>
        public string this[string input]
        {
            get
            {
                SHA512CryptoServiceProvider x = new SHA512CryptoServiceProvider();
                byte[] byteString = Encoding.UTF8.GetBytes(input);
                byteString = x.ComputeHash(byteString);
                StringBuilder s = new StringBuilder();

                foreach (byte b in byteString)
                {
                    s.Append(b.ToString("x2").ToLower());
                }
                return s.ToString();
            }
        }
    }
}